package com.msmall.community.admin.action;

import java.io.IOException;

import com.msmall.base.action.HTMLBaseAction;
import com.msmall.base.util.ConstantDB;
import com.msmall.community.common.model.Abuse;
import com.msmall.community.common.service.AbuseManager;

public class AbuseAction extends HTMLBaseAction{

	private static final long serialVersionUID = -3615726602217497159L;

	private Long abuseId;
	
	private Abuse abuse;
	
	private AbuseManager abuseManager;
	
	// 举报首页
	public String execute(){
		page.setClazz(Abuse.class);
		page.setPageSize(20);
		page.setOrderBy("reportTime");
		page.setOrder("desc");
		abuseManager.getPagination(page);
		return SUCCESS;
	}

	public void pass(){
		try{
			abuseManager.audit(abuseId, ConstantDB.AUDIT_PASS, getUserid(), "");
			getResponse().getWriter().write(getText("common.audit.success"));
		}catch(Exception e){
			log.debug(e);
			try {
				getResponse().getWriter().write(getText("common.audit.fail"));
			} catch (IOException e1) {
			}
		}
	}
	public void reject(){
		try{
			abuseManager.audit(abuseId, ConstantDB.AUDIT_REJECT, getUserid(), "");
			getResponse().getWriter().write(getText("common.audit.success"));
		}catch(Exception e){
			log.debug(e);
			try {
				getResponse().getWriter().write(getText("common.audit.fail"));
			} catch (IOException e1) {
			}
		}
	}
	public Long getAbuseId() {
		return abuseId;
	}

	public void setAbuseId(Long abuseId) {
		this.abuseId = abuseId;
	}

	public Abuse getAbuse() {
		return abuse;
	}

	public void setAbuse(Abuse abuse) {
		this.abuse = abuse;
	}

	public void setAbuseManager(AbuseManager abuseManager) {
		this.abuseManager = abuseManager;
	}
}
